﻿using System.Linq;
using eCommerce.Core.Data;
using eCommerce.Core.Domain.Messges;

namespace eCommerce.Services.Messages
{
    public class MessageService:IMessageService
    {
        private IRepository<Message> _messageRep;

        public MessageService(IRepository<Message> messageRep)
        {
            _messageRep = messageRep;
        }

        public string GetResourceValue(string resourceName, int languageId)
        {
            var query = from m in _messageRep.Table
                        where m.ResourceName == resourceName && m.Languageid == languageId
                        select m;
            var t = query.SingleOrDefault();
            if (t != null)
            {
                return t.ResourceValue;
            }
            return string.Empty;


        }
    }
}